package com.copsoftware.support;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Session;

import com.copsoftware.db.DAODataLoader;
import com.copsoftware.exceptionutils.DAODataLoaderException;
import com.copsoftware.hibernate.cfg.HibernateUtils;
import com.copsoftware.utils.constants.CSConstants;


public class DataLoader {
	
	public static List proccess(String queryType,String query)
	{
		List listOfLabelValue=null;
		try{
			Session session = HibernateUtils.getSessionFactory().getCurrentSession();
			session.beginTransaction();
			DAODataLoader daoDataLoader = new DAODataLoader();
			daoDataLoader.setSession(session);
			if (CSConstants.TIPO_QUERY_HQL.equals(queryType))
				listOfLabelValue = daoDataLoader.list(query);
			session.getTransaction().commit();
			return listOfLabelValue;
		}
		catch(DAODataLoaderException de)
		{
			if (! de.isLogged())
			{
				Log log = LogFactory.getLog("DataLoader");
				de.log(log);
			}			
		}
		return null;
	}
	
}
